<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>设备管理</title>
	<meta name="decorator" content="default"/>
    <%@include file="/WEB-INF/views/include/treetable.jsp" %>
	<script type="text/javascript">
        $(document).ready(function() {
            var tpl = $("#treeTableTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
            var data = ${fns:toJson(list)}, rootId = "${not empty office.id ? office.id : '0'}";
            addRow("#treeTableList", tpl, data, rootId, true);
            $("#treeTable").treeTable({expandLevel : 5});
        });
        function addRow(list, tpl, data, pid, root){
            for (var i=0; i<data.length; i++){
                var row = data[i];
                if ((${fns:jsGetVal('row.parentId')}) == pid){
                    $(list).append(Mustache.render(tpl, {
                        dict: {
                            type: getDictLabel(${fns:toJson(fns:getDictList('sys_office_type'))}, row.type)
                        }, pid: (root?0:pid), row: row
                    }));
                    addRow(list, tpl, data, row.id);
                }
            }
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active">
            <a href="${ctx}/equipment/eleEquipment/">
                <spring:message code="device.list"/>
            </a>
        </li>
		<shiro:hasPermission name="equipment:eleEquipment:edit">
            <li>
                <a href="${ctx}/equipment/eleEquipment/form">
                    <spring:message code="device.add"/>
                </a>
            </li>
        </shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="eleEquipment" action="${ctx}/equipment/eleEquipment/" method="post" class="breadcrumb form-search">
		<ul class="ul-form">
			<li><label><spring:message code="type"/>：</label>
				<sys:treeselect id="type" name="type.id" value="${eleEquipment.type.id}"
								labelName="type.name" labelValue="${eleEquipment.type.name}"
								title="<spring:message code='menu.device.Equipment_Type'/>" url="/equipment/eleEquipmentType/treeData" cssClass="required input-small"/>
			</li>
            <shiro:hasRole name="admin">
                <li>
                    <label><spring:message code="common.company"/>：</label>
                    <sys:treeselect id="company" name="company.id" value="${eleEquipment.company.id}" labelName="company.name"
                                    labelValue="${eleEquipment.company.name}"
                                    title="<spring:message code='common.company'/>" url="/sys/office/treeData?type=1" cssClass="input-small" allowClear="true"/>
                </li>
			</shiro:hasRole>
            <li>
                <label><spring:message code='common.group'/>：</label>
                <shiro:lacksRole name="admin">
                    <input id="companyId" name="company.id" value="${eleEquipment.company.id}" type="hidden">
                </shiro:lacksRole>
                <sys:treeselect id="office" name="office.id" value="${eleEquipment.office.id}" labelName="office.name"
                                labelValue="${eleEquipment.office.name}"
                                title="<spring:message code='common.group'/>" url="/sys/office/treeData?type=2" cssClass="input-small" allowClear="true" notAllowSelectParent="true"/>
            </li>
            <li>
                <label style="width: 0;"></label>
                <spring:message code="common.device.id" var="deviceId"/>
                <form:input path="code" htmlEscape="false" maxlength="50" class="input-medium" placeholder="${deviceId}"/>
            </li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="<spring:message code='common.Query'/>"/></li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="button" value="<spring:message code='common.refresh'/>" onclick="window.location.reload();"/>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
    <table id="treeTable" class="table table-striped table-bordered table-condensed">
        <thead>
        <tr>
            <th>
                <spring:message code='common.organization'/>
            </th>
            <th>
                <spring:message code="common.device.id"/>
            </th>
            <th>
                <spring:message code="device.name"/>
            </th>
            <th>
                <spring:message code="device.type"/>
            </th>
            <th>
                <spring:message code='common.resolution'/>
            </th>
            <th>
                <spring:message code='common.online'/>
            </th>

            <shiro:hasPermission name="equipment:eleEquipment:edit">
                <th>
                    <spring:message code='common.operation'/>
                </th>
            </shiro:hasPermission>
            <th>
                <spring:message code='common.remarks'/>
            </th>
        </tr>
        </thead>
        <tbody id="treeTableList"></tbody>
    </table>
    <script type="text/template" id="treeTableTpl">
        <tr id="{{row.id}}" pId="{{pid}}">
            <td>{{row.name}}</td>
            <td>
                <a href="${ctx}/equipment/eleEquipment/info?id={{row.id}}">
                {{row.address}}
                </a>
            </td>
			<td>{{row.zipCode}}</td>
            <td>{{row.email}}</td>
            <td>{{row.fax}}</td>
 			<td>
			{{row.grade}}
				</td>

            <shiro:hasPermission name="equipment:eleEquipment:edit">
                <td>
                    <div style="{{row.phone}}">
                        <a href="${ctx}/equipment/eleEquipment/form?id={{row.id}}"><spring:message code="common.modify"/></a>
                        <a href="${ctx}/equipment/eleEquipment/monitor?id={{row.id}}"><spring:message code='common.monitor'/></a>
						<a href="${ctx}/equipment/eleEquipmentLog/list?equipmentId={{row.id}}&type=log"><spring:message code='common.log'/></a>
                        <a href="${ctx}/equipment/eleEquipmentLog/list?equipmentId={{row.id}}&type=realtime"><spring:message code='common.screen'/></a>
						<a href="${ctx}/equipment/eleEquipment/delete?id={{row.id}}" onclick="return confirmx('<spring:message code='tips.deleq' />', this.href)"><spring:message code='common.delete'/></a>
                   </div>
                </td>
            </shiro:hasPermission>
            <td>{{row.remarks}}</td>
        </tr>
    </script>
</body>
</html>